package picoevo.ext.evolution;

import picoevo.core.evolution.InitialisationOperator_Element;
import picoevo.core.representation.Element;
import picoevo.ext.representation.Element_Bit;
import picoevo.toolbox.Display;

public class InitialisationOperator_Element_Bit extends InitialisationOperator_Element {

	// ### Constructors ###

	public InitialisationOperator_Element_Bit() {
		super();
	}

	public InitialisationOperator_Element_Bit(String __name) {
		super(__name);
	}

	// ### Methods ###

	@Override
	public void initialise(Element __o) {
		try {
			Element_Bit element = (Element_Bit) __o;

			double value = Math.random();
			if (value < 0.5)
				element.setValue(false);
			else
				element.setValue(true);
		} catch (java.lang.ClassCastException e) {
			Display.error("" + this.getClass().getName() + "::initialise(.) - Class cast exception");
		}
	}

}
